﻿<fluent:RibbonWindow x:Class="WhiteFlow.DevTrackingTool.UI.Views.MainView"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
                     xmlns:wfControls="clr-namespace:WhiteFlow.Wpf.Controls.Common;assembly=WhiteFlow.Wpf.Controls"
                     xmlns:behaviors="clr-namespace:WhiteFlow.DevTrackingTool.UI.Behaviors"
                     xmlns:converters="clr-namespace:WhiteFlow.DevTrackingTool.UI.Converters"
                     xmlns:views="clr-namespace:WhiteFlow.DevTrackingTool.UI.Views"
                     xmlns:controls="clr-namespace:WhiteFlow.DevTrackingTool.UI.Controls"
                     WindowState="Maximized"
                     Foreground="White"
                     Height="400" 
                     Width="753" 
                     Background="{StaticResource ResourceKey=MainBgBrush}"
                     Icon="/WhiteFlow.DevTrackingTool.UI;component/Resources/Icons/Application/ApplicationIcon.ico"
                     Title="{Binding Path=WorksheetViewModel.Worksheet.TitleToDisplayInTabHeader, StringFormat='Dev Tracking Tool - {0}', TargetNullValue='Dev Tracking Tool', FallbackValue='Dev Tracking Tool'}"
                     behaviors:WindowClosingToCommandBehavior.Command="{Binding Path=ExitCommand}">

    <fluent:RibbonWindow.Resources>
        <converters:BackstageTabConverter x:Key="BackstageTabConverter" />
        <converters:IsNullToBooleanConverter x:Key="IsNullToBooleanConverter" />
        <converters:IsNotNullToBooleanConverter x:Key="IsNotNullToBooleanConverter" />
        <converters:TimeSpanConverter x:Key="TimeSpanConverter" />
        <converters:CurrencyToLanguageConverter x:Key="CurrencyToLanguageConverter" />
    </fluent:RibbonWindow.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <fluent:Ribbon Name="RibbonBar" 
                       CanCustomizeRibbon="False"
                       IsManipulationEnabled="False"
                       AutomaticStateManagement="False"
                       IsMinimized="False"
                       SelectedTabIndex="{Binding Path=CurrentBackstageTab, Mode=TwoWay, Converter={StaticResource ResourceKey=BackstageTabConverter}}"
                       IsEnabled="{Binding Path=IsClosed, ElementName=MsgDialog}">

            <fluent:Ribbon.QuickAccessItems>
                <fluent:QuickAccessMenuItem Target="{Binding ElementName=SaveButton}" IsChecked="True" />
                <fluent:QuickAccessMenuItem Target="{Binding ElementName=SaveAsButton}" IsChecked="True" />
                <fluent:QuickAccessMenuItem Target="{Binding ElementName=OpenButton}" IsChecked="True" />
                <fluent:QuickAccessMenuItem Target="{Binding ElementName=CloseButton}" IsChecked="True" />
            </fluent:Ribbon.QuickAccessItems>

            <!--<fluent:Ribbon.ContextualGroups>
                <fluent:RibbonContextualTabGroup x:Name="wsCtxTabGroup"
                                                 Header="Worksheet"
                                                 Visibility="{Binding Path=WorksheetCommandBarVisibility}"
                                                 Background="Green"
                                                 BorderBrush="Green" />
            </fluent:Ribbon.ContextualGroups>-->

            <fluent:Ribbon.Menu>
                <fluent:Backstage Header="Start"
                                  IsOpen="{Binding Path=IsBackstageOpen, Mode=TwoWay}"
                                  Background="{StaticResource ResourceKey=BackstageBgBrush}">
                    <fluent:BackstageTabControl>
                        <fluent:Button x:Name="SaveButton" 
                                                  Header="Save" 
                                                  Command="{Binding Path=SaveActiveWorksheetCommand}"
                                                  Size="Middle"
                                                  Icon="pack://application:,,,/Resources/Icons/Application/disk.png" />
                        <fluent:Button x:Name="SaveAsButton" 
                                                  Header="Save as"
                                                  Command="{Binding Path=SaveActiveWorksheetAsCommand}"
                                                  Size="Middle"
                                                  Icon="pack://application:,,,/Resources/Icons/Application/save_as.png" />
                        <fluent:Button x:Name="OpenButton" 
                                                  Header="Open"
                                                  Command="{Binding Path=OpenWorksheetCommand}"
                                                  Size="Middle"
                                                  Icon="pack://application:,,,/Resources/Icons/Application/folder.png" />
                        <fluent:Button x:Name="CloseButton" 
                                                  Header="Close"
                                                  Command="{Binding Path=CloseActiveWorksheetCommand}"
                                                  Size="Middle"
                                                  Icon="pack://application:,,,/Resources/Icons/Application/move_to_folder.png" />

                        <fluent:BackstageTabItem Header="Recent">
                            <views:BackstageRecentTabView DataContext="{Binding Path=BackstageRecentTabViewModel}" />
                            </fluent:BackstageTabItem>

                        <fluent:BackstageTabItem Header="New">
                            <views:BackstageNewTabView />
                        </fluent:BackstageTabItem>

                        <fluent:Button Header="Exit"
                                       Command="{Binding Path=ExitCommand}"
                                       Size="Middle"
                                       Icon="pack://application:,,,/Resources/Icons/Application/door_in.png" />
                    </fluent:BackstageTabControl>
                </fluent:Backstage>
            </fluent:Ribbon.Menu>

            <fluent:RibbonTabItem Header="Manage" 
                                  ReduceOrder="Large, Large, Large">
                <!--Group="{Binding ElementName=wsCtxTabGroup}">-->
                <fluent:RibbonGroupBox Header="Tasks"
                                       IsEnabled="{Binding Path=WorksheetViewModel, Converter={StaticResource ResourceKey=IsNotNullToBooleanConverter}}">
                    <fluent:DropDownButton Header="Add"
                                           LargeIcon="pack://application:,,,/Resources/Icons/Application/32x32/pencil_add.png"
                                           Size="Large">
                        <DockPanel LastChildFill="True">
                            <Border DockPanel.Dock="Bottom"
                                    Padding="0,2,0,0"
                                    BorderThickness="0,1,0,0"
                                    BorderBrush="LightGray">
                                <fluent:MenuItem Header="From Template..."
                                                 Icon="pack://application:,,,/Resources/Icons/Application/16x16/plugin_go.png"
                                                 ToolTip="This feature is not implemented yet" />
                            </Border>

                            <Border Background="White" Padding="0,0,0,2">
                                <StackPanel Orientation="Vertical">
                                    <Button Foreground="#303030"
                                            Command="{Binding Path=WorksheetViewModel.TasksListViewModel.AddTaskCommand}"
                                            Style="{StaticResource ResourceKey=HoverButtonStyle}">
                                        <Button.Content>
                                            <DockPanel LastChildFill="True">
                                                <wfControls:Bitmap Source="pack://application:,,,/Resources/Icons/Application/32x32/hammer.png" DockPanel.Dock="Left" VerticalAlignment="Center" />
                                                <StackPanel Margin="5,0,0,0" Orientation="Vertical" VerticalAlignment="Center">
                                                    <TextBlock Text="Empty Task" FontWeight="Bold" />
                                                    <TextBlock Text="Creates an empty task, where all fields can be changed." />
                                                </StackPanel>
                                            </DockPanel>
                                        </Button.Content>
                                        <!--<Button.ToolTip>
                                            <fluent:ScreenTip Title="Test screen-tip"
                                                          Image="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/32x32/timeline.png"
                                                          Text="This is a test description for this button." />
                                        </Button.ToolTip>-->
                                    </Button>
                                    <Button Foreground="#303030"
                                            ToolTip="This feature is not implemented yet"
                                            Style="{StaticResource ResourceKey=HoverButtonStyle}">
                                        <Button.Content>
                                            <DockPanel LastChildFill="True">
                                                <wfControls:Bitmap Source="pack://application:,,,/Resources/Icons/Application/32x32/server_link.png" DockPanel.Dock="Left" VerticalAlignment="Center" />
                                                <StackPanel Margin="5,0,0,0" Orientation="Vertical" VerticalAlignment="Center">
                                                    <TextBlock Text="From TFS WorkItem" FontWeight="Bold" />
                                                    <TextBlock Text="Add a task linked to a TFS WorkItem" />
                                                </StackPanel>
                                            </DockPanel>
                                        </Button.Content>
                                    </Button>
                                </StackPanel>
                            </Border>
                        </DockPanel>
                    </fluent:DropDownButton>
                    <Separator />
                    <fluent:Button Header="Insert"
                                   Size="Middle"
                                   Command="{Binding Path=WorksheetViewModel.TasksListViewModel.InsertTaskCommand}"
                                   Icon="pack://application:,,,/Resources/Icons/Application/table_insert.png" />
                    <fluent:Button Header="Delete selected"
                                   Size="Middle"
                                   Command="{Binding Path=WorksheetViewModel.TasksListViewModel.DeleteSelectedTaskCommand}"
                                   Icon="pack://application:,,,/Resources/Icons/Application/table_row_delete.png" />
                    <Separator />
                    <fluent:Button Header="Clear tracking for current day"
                                   Size="Large"
                                   Command="{Binding Path=WorksheetViewModel.TasksListViewModel.ClearTrackingCommand}"
                                   LargeIcon="pack://application:,,,/Resources/Icons/Application/32x32/font_red_delete.png" />
                </fluent:RibbonGroupBox>
                <fluent:RibbonGroupBox Header="Expenses"
                                       IsEnabled="{Binding Path=WorksheetViewModel, Converter={StaticResource ResourceKey=IsNotNullToBooleanConverter}}">
                    <fluent:Button Header="Add"
                                   Size="Large"
                                   Command="{Binding Path=WorksheetViewModel.ExpensesReportViewModel.AddExpenseCommand}"
                                   LargeIcon="pack://application:,,,/Resources/Icons/Application/32x32/coins_add.png" />
                    <fluent:Button Header="Delete selected"
                                   Size="Large"
                                   Command="{Binding Path=WorksheetViewModel.ExpensesReportViewModel.DeleteSelectedExpenseCommand}"
                                   LargeIcon="pack://application:,,,/Resources/Icons/Application/32x32/coins_delete.png" />
                </fluent:RibbonGroupBox>
                <fluent:RibbonGroupBox Header="Settings"
                                       IsEnabled="{Binding Path=WorksheetViewModel, Converter={StaticResource ResourceKey=IsNotNullToBooleanConverter}}">
                    <fluent:TextBox Icon="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/16x16/timeline.png" 
                                    Text="{Binding Path=WorksheetViewModel.Worksheet.WorksheetSettings.ContractWorkdayDuration, Mode=TwoWay, Converter={StaticResource ResourceKey=TimeSpanConverter}}"
                                    TextAlignment="Right"
                                    VerticalContentAlignment="Center">
                        <fluent:TextBox.ToolTip>
                            <fluent:ScreenTip Title="Workday duration"
                                              Image="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/32x32/timeline.png"
                                              Text="The duration of a workday, according to terms of contract." />
                        </fluent:TextBox.ToolTip>
                    </fluent:TextBox>
                    <fluent:ComboBox Icon="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/16x16/money_dollar.png"
                                     Text="{Binding Path=WorksheetViewModel.Worksheet.WorksheetSettings.Currency, Converter={StaticResource ResourceKey=CurrencyToLanguageConverter}}" 
                                     IsEditable="False" 
                                     ScrollViewer.VerticalScrollBarVisibility="Auto">
                    
                        <fluent:ComboBox.ToolTip>
                            <fluent:ScreenTip Title="Currency Symbol"
                                              Image="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/32x32/money_dollar.png"
                                              Text="The symbol used to represent currency values." />
                        </fluent:ComboBox.ToolTip>

                        <ComboBoxItem Content="DOLLAR" />
                        <ComboBoxItem Content="EURO" />
                    </fluent:ComboBox>
                    <fluent:TextBox Icon="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/16x16/car.png"
                                    Text="{Binding Path=WorksheetViewModel.Worksheet.WorksheetSettings.RefundPerKilometer, Mode=TwoWay}"
                                    TextAlignment="Right"
                                    VerticalContentAlignment="Center">
                        <fluent:TextBox.ToolTip>
                            <fluent:ScreenTip Title="Refund per Kilometer"
                                              Image="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/32x32/car.png"
                                              Text="This value represents the amount of money refunded for a Kilometer. &#x0a;It will be used to calculate the amount of an expense based on the kilometers covered during work trips." />
                        </fluent:TextBox.ToolTip>
                    </fluent:TextBox>
                </fluent:RibbonGroupBox>
            </fluent:RibbonTabItem>
            
            <fluent:RibbonTabItem Header="Connections"
                                  ReduceOrder="Large, Large, Large">
                <fluent:RibbonGroupBox Header="TFS 2010">
                    <fluent:DropDownButton Header="Connect/Disconnect"
                                           Size="Large"
                                           LargeIcon="pack://application:,,,/Resources/Icons/Application/32x32/server_connect.png">
                        <DockPanel LastChildFill="True">
                            <!--<Border DockPanel.Dock="Bottom"
                                    Padding="0,2,0,0"
                                    BorderThickness="0,1,0,0"
                                    BorderBrush="LightGray">
                                <fluent:MenuItem Header="From Template..."
                                                 Icon="pack://application:,,,/Resources/Icons/Application/16x16/plugin_go.png"
                                                 Opacity="0.5"
                                                 ToolTip="This feature is not implemented yet" />
                            </Border>-->

                            <Border Background="White" Padding="0,0,0,2">
                                <StackPanel Orientation="Vertical">
                                    <Button Foreground="#303030"
                                            Command="{x:Null}"
                                            ToolTip="This feature is not implemented yet"
                                            Style="{StaticResource ResourceKey=HoverButtonStyle}">
                                        <Button.Content>
                                            <DockPanel LastChildFill="True">
                                                <wfControls:Bitmap Source="pack://application:,,,/Resources/Icons/Application/32x32/connect.png" DockPanel.Dock="Left" VerticalAlignment="Center" />
                                                <StackPanel Margin="5,0,0,0" Orientation="Vertical" VerticalAlignment="Center">
                                                    <TextBlock Text="Connect to Team Project Collection" FontWeight="Bold" />
                                                    <TextBlock Text="Connect to a TFS 2010 Team Project Collection." />
                                                </StackPanel>
                                            </DockPanel>
                                        </Button.Content>
                                        <!--<Button.ToolTip>
                                            <fluent:ScreenTip Title="Test screen-tip"
                                                          Image="pack://application:,,,/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/32x32/timeline.png"
                                                          Text="This is a test description for this button." />
                                        </Button.ToolTip>-->
                                    </Button>
                                    <Button Foreground="#303030"
                                            Command="{x:Null}"
                                            ToolTip="This feature is not implemented yet"
                                            Style="{StaticResource ResourceKey=HoverButtonStyle}">
                                        <Button.Content>
                                            <DockPanel LastChildFill="True">
                                                <wfControls:Bitmap Source="pack://application:,,,/Resources/Icons/Application/32x32/disconnect.png" DockPanel.Dock="Left" VerticalAlignment="Center" />
                                                <StackPanel Margin="5,0,0,0" Orientation="Vertical" VerticalAlignment="Center">
                                                    <TextBlock Text="Disconnect from current Team Project Collection" FontWeight="Bold" />
                                                    <TextBlock Text="Disconnects from the currently configured Team Project Collection." />
                                                </StackPanel>
                                            </DockPanel>
                                        </Button.Content>
                                    </Button>
                                </StackPanel>
                            </Border>
                        </DockPanel>
                    </fluent:DropDownButton>
                </fluent:RibbonGroupBox>
            </fluent:RibbonTabItem>
        </fluent:Ribbon>

        <views:WorksheetView Grid.Row="1" 
                             DataContext="{Binding Path=WorksheetViewModel}"
                             Margin="2" 
                             BorderThickness="0"
                             Panel.ZIndex="1" />

        <controls:MessageDialog x:Name="MsgDialog"
                                Grid.Row="1"
                                Margin="2" 
                                Panel.ZIndex="2" />

    </Grid>

</fluent:RibbonWindow>